<template>
  <div class="header-top">
    <div class="header-content">
      <div class="menu">
        <div v-for="(item, index) in menu" :key="index"
          :class="item.path == router.currentRoute.value.path ? 'nav-item active' : 'nav-item'"
          @click="changeNav(item)">
          {{ item.name }}
        </div>
      </div>
      <div class="search" v-if="fullpath == '/'">
        <form method="post">
          <img src="../assets/Imgs/info.png" alt="" />
          <input type="text" name="condition" placeholder="请输入搜索条件">
          <input type="submit" @click="goSeach()" value="搜索">
        </form>
      </div>
      <div class="login" v-if="!loginStatus" @click="router.push('/login')">
        <span>去登录</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { storeToRefs } from 'pinia'



// const userInfoStore = useUserInfoStore()
const loginStatus = false

import { ref, inject, watch } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const fullpath = router.currentRoute.value.path
const emit = defineEmits(['onSearch'])
let activeID = ref(0)
// import emitter from '@/utils/mitter'
function changeNav(item: any) {
  // activeID.value = item.id
  // emitter.emit('get-cate_id', item.id)
  router.push({ path: item.path })
}
function updateNav(item: number) {
  activeID.value = item
}



const getList = inject<any>('getList')
const search = () => {
  getList()
  emit('onSearch')
}

function allGoods() {
  activeID.value = 0
  // emitter.emit('get-cate_id', '')
  // router.push('/class')
}
const goSeach = () => {

}
watch(() =>
  console.log(router.currentRoute.value.path),
)
const menu = [
  {
    name: '首页',
    path: '/'
  },
  {
    name: '消息通知',
    path: '/message'
  },
  {
    name: '个人信息',
    path: '/userInfo'
  },
  {
    name: '举报',
    path: '/report'
  },
]

</script>

<style lang="scss" scoped>
.top {
  height: 30px;
  width: 100%;
  background-color: var(--grey);

  .content {
    margin: 0 auto;
    width: var(--wd);
    height: 100%;

    .left {
      color: #a2a2a2;
      font-size: 14px;
      cursor: pointer;

      &:hover {
        color: #4bb4da;
      }
    }

    .right {

      .login,
      .register {
        cursor: pointer;
        height: 30px;
        padding: 0 10px;
        font: 14px/30px '微软雅黑';
        color: #4bb4da;

        &:hover {
          background-color: #fff;
        }
      }
    }
  }
}

.bottom {
  height: 140px;
  background: #fff;

  .container {
    height: 100px;
    width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .shop-logo {
      height: 90px;
      width: 200px;
      cursor: pointer;
    }

    .empty-box {
      width: 76px;
      height: 84px;
      background: #ffffff;
    }

    .search-container {
      width: 610px;
      padding: 0 10px;
      height: 40px;
      border-radius: 16px;
      border: 1px solid #41b0d9;
      display: flex;
      align-items: center;
      justify-content: space-between;

      ::v-deep(.search-input) {
        width: 520px;

        .el-input__wrapper {
          padding: 0 !important;
          box-shadow: none !important;
        }
      }

      .search-button {
        cursor: pointer;
        text-align: center;
        line-height: 32px;
        color: #ffffff;
        font-size: 20px;
        width: 70px;
        height: 32px;
        background: #41b0d9;
        border-radius: 16px;
      }
    }
  }
}

.nav {
  margin-top: 20px;
  width: 1280px;
  height: 40px;
  display: flex;
  margin: 0 auto;
  align-items: center;
  overflow: hidden;
}

.nav-fix {
  flex-shrink: 0;
  width: 198px;
  height: 38px;
  border: 1px solid #41b0d9;
  text-align: center;
  line-height: 40px;
  font-size: 18px;
  color: #41b0d9;
  margin-right: 20px;
  cursor: pointer;
}



.nav-item {
  flex-shrink: 0;
  cursor: pointer;
  height: 26px;
  line-height: 26px;
  font-size: 16px;
  padding: 0 10px;
  border-radius: 13px;
  margin-right: 20px;
}

.header-top {
  height: 60px;
  background: #555c64;

  .header-content {
    width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    overflow: hidden;

    .menu {
      width: 33%;
      align-items: center;
      overflow: hidden;
      display: flex;
      height: 60px;

      .nav-item {
        flex-shrink: 0;
        cursor: pointer;
        height: 60px;
        line-height: 60px;
        font-size: 16px;
        padding: 0 10px;
        border-radius: 13px;
        margin-right: 20px;
      }

      .nav-fix {
        flex-shrink: 0;
        width: 198px;
        height: 38px;
        // border: 1px solid #41b0d9;
        text-align: center;
        line-height: 60px;
        font-size: 18px;
        color: #fff;
        margin-right: 20px;
        cursor: pointer;
      }

      .active {
        // background-color: $themeColor;
        color: #5076ca;
      }
    }

    div.search {
      height: 36px;
      width: 650px;
      display: flex;
    }

    div.search form {
      width: 100%;
      height: 100%;
      position: relative;
    }

    div.search form input:nth-child(2) {
      width: 550px;
      height: 100%;
      font-size: 16px;
      height: 34px;
      text-indent: 40px;
      border: none;
      float: left;
    }

    div.search form input:nth-child(3) {
      width: 80px;
      height: 100%;
      font-size: 16px;
      letter-spacing: 5px;
      border: none;
    }

    div.search form img {
      position: absolute;
      left: 0px;
      margin-top: 8px;
      margin-left: 8px;
      height: 20px;
    }

    .login {
      width: 150px;
      float: right;
      color: #4885e2;
      flex-shrink: 0;
      cursor: pointer;
      height: 60px;
      line-height: 60px;
      font-size: 16px;
      text-align: right;
      padding-right: 20px;
    }
  }
}
</style>
